package pl.un4giv3n.mightvsmagic.utils;

import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Formatter;

/**
 * @author andrzejewskia 
 * Util for formatting
 */
public class FormatterUtil {

	/**
	 * date format instance for date formatting
	 */
	private static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy K:mm:ss a");
	/**
	 * number format instance for number formatting
	 */
	private static NumberFormat nf = NumberFormat.getInstance();
	static {
		nf.setMinimumFractionDigits(2);
		nf.setMaximumFractionDigits(2);
	}

	private FormatterUtil() {
	}

	/**
	 * @param date
	 *            -date to format
	 * @return formatted date
	 */
	public static String formatDate(Date date) {
		return sdf.format(date);
	}

	public static String getSystemTime(){
		return sdf.format(new Date());
	}
	
	/**
	 * @param damage
	 *            - damage to format
	 * @return formatted damage
	 */
	public static String formatDamage(double damage) {
		return nf.format(damage);
	}
	
	/**
	 * @param hash
	 * @return string representation of byte hash
	 */
	public static String byteArray2Hex(byte[] hash) {
        Formatter formatter = new Formatter();
        for (byte b : hash) {
            formatter.format("%02x", b);
        }
        return formatter.toString();
    }

}
